<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>roleManage 角色管理</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/less/common_less.css" />
	<style>
		.Dolo_searchPanle{
			line-height:30px;
			height:30px;
		}
		.Dolo_searchPanle span{
			margin-left:15px;
		}
		
		.btn{
			float:right;
			margin-right:20px;
		}

		.tableData{
			width:1100px;
			margin-left:4px;
			background:white;
			margin-top:5px;
			padding:20px;
			border-top:1px solid white;
		}
		.tableData table{			
			width:1100px;
		}
		.tableData table th,td{
			height:40px;
			border:1px solid #ebebeb;
		}
		.tableHead{
			background:#f0eeef;
			color:#7f868c;
		}
		.accredit,.edit{
			margin:0 5px;
			cursor:pointer;
		}
	</style>
	<body>
		<div class="Dolo_searchPanle">
		<p>
			<span class='btn'>
				<button class='newSeriesBtn add'><i class="iconfont setIcon">&#xe627;</i>添加</button>
			</span>									
		</p>		
		</div>
		<div class='tableData'>
			<table id="dataTable">
				<thead>
					<tr class='tableHead'>
						<th>角色名称</th>
						<th>角色描述</th>
						<th>状态</th>
						<th>操作</th>						
					</tr>
				</thead>
				<tbody class='clear'></tbody>									
			</table>
		</div>
		<div class='Pagination'></div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../js/jquery.freezeheader.js" ></script>
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<script>
		//____________________________________________________________________________渲染页面
			
			var totalAmount
			var totalPage
			var nowPage
			function getAjax(){
				var pageNum = $(".page").val()-0;
				var pageSize = $(".pageSize").val()-0;
				$.get("../role/query?pageNum="+pageNum+"&pageSize="+pageSize+"&temp="+Math.random(),function(data){
					data = JSON.parse(data)
					totalAmount = data.data.total
					totalPage = data.data.pages
					nowPage = data.data.pageNum
					//共多少条
					$(".totalAmount").text(totalAmount)
					//共多少页
					$(".totalPage").text(totalPage)
					//第几页
					$(".nowPage").text(nowPage)
					$(".clear").empty()
					var str="";
					for(var i=0;i<data.data.list.length;i++){
						if(data.data.list[i].state=="vd"){
							data.data.list[i].state="有效"
						}else if(data.data.list[i].state=="ud"){
							data.data.list[i].state="无效"
						}else{
							data.data.list[i].state="未知状态"
						}
						str+="<tr>"+
								"<td class='id' style='display:none;'>"+data.data.list[i].id+"</td>"+
								"<td>"+data.data.list[i].name+"</td>"+
								"<td>"+data.data.list[i].description+"</td>"+
								"<td>"+data.data.list[i].state+"</td>"+
								"<td><span class='accredit'>授权</span><span class='edit'>编辑</span></td>"+
							 "</tr>"
					}
					$(".clear").append(str)
				})
			}
		
		
		
		//____________________________________________________________________________添加角色
			$(".add").click(function(){
				layer.open({
					type: 2,
					title: ['添加角色','background-color:#6d6e72; color:#fff;font-size:14px;'],
					shadeClose: true,
					shade: [0.9,'#cfcfcf'],
					area: ['430px', '250px'],  
					content: ['../ak/addRole.html'],// iframe的url，no代表不显示滚动条
					end:function(){
						getAjax()
					}
						
				});
			})
			
		//____________________________________________________________________________授权
			$(".clear").delegate(".accredit","click",function(){
				var postId = $(this).parent().parent().find("td[class='id']").text()
				layer.open({
					type: 2,
					title: ['授权','background-color:#6d6e72; color:#fff;font-size:14px;'],
					shadeClose: true,
					shade: [0.9,'#cfcfcf'],
					area: ['430px', '480px'],  
					content: ['../ak/accredit.html?postId='+postId,"no"],// iframe的url，no代表不显示滚动条
					end:function(){
						getAjax()
					}
						
				});
			})
		//________________________________________表头固定____________________________________________
			$("#dataTable").freezeHeader();	
		
		//________________________________________分页__________________________________
			$(".Pagination").load("Pagination.html",function(){
				getAjax();
			})		
		//____________________________________________________________________________修改角色
			
			
			$(".clear").delegate(".edit","click",function(){
				var postId = $(this).parent().parent().find("td[class='id']").text()
				layer.open({
					type: 2,
					title: ['修改角色','background-color:#6d6e72; color:#fff;font-size:14px;'],
					shadeClose: true,
					shade: [0.9,'#cfcfcf'],
					area: ['430px', '250px'],  
					content: ['../ak/addRole.html?postId='+postId],// iframe的url，no代表不显示滚动条
					end:function(){
						getAjax()
					}
						
				});
			})
		</script>
	</body>
</html>
